<template>
    <div :class="$style.root">
      <div :class="$style.title">
        {{ $t('langObj.hadBuyPro') }}:
      </div>
      <project-desc v-for="item in taskList" :key="item.taskId" 
          :item="item"
          @projectShare="projectShare"
          @projectRelease="projectRelease"
          @projectDelete="deletePro">
      </project-desc>
    </div>
</template>

<script>
import { mapActions } from 'vuex';
import projectDesc from '@/components/user/projectDesc';
export default {
    components:{projectDesc},
    data(){
        return{
            id:this.$route.params.id,
            taskList:[],
        }
    },
    methods: {
        ...mapActions(['XgetNotebookList','XprojectShare','XprojectRelease','XprojectDelete']),
        projectShare(taskId){
            this.XprojectShare(taskId).then(res => {
                this.$Message.success("分享成功")
            })
            .catch(err => {
                this.$Message.error(err.response.data.message)
            })
        },
        projectRelease(params){
            this.XprojectRelease(params).then(res => {
                this.$Message.success("释放成功");
                this._pageMounte();
            })
            .catch(err => {
                this.$Message.error(err.response.data.message)
            })
        },
        deletePro(taskId){
            this.XprojectDelete(taskId).then(res => {
                this.$Message.success("删除成功");
                this._pageMounte();
            })
            .catch(err => {
                this.$Message.error(err.response.data.message)
            })
        },
        _pageMounte(){
          this.XgetNotebookList({
              type:0,
              dataId:this.id,
            }).then(res => {
                this.taskList = res.data
            })
        }
    },
    created() {
        this._pageMounte()
    },
}
</script>

<style module>
.root {
  width:1200px;
  margin: 0 auto;
  padding:50px;
  background-color:#f9fafa;
}

.title {
  font-size: 24px;
  color: #17233d;
  margin-bottom:20px;
}

</style>

